package com.android.stockme.backend.news;

import com.android.stockme.backend.fetcher.INewsItem;
import java.util.Collection;
import java.util.List;
import java.util.SortedSet;

/**
 * 
 * @author Avishay
 *
 * This interface represents a News Updates Center which maintains all news updates.
 * 
 * It allows users to register event listeners through which they are notified when the
 * database is updated.
 * 
 * It also allows users to query the database and retrieve the news updates (sorted by
 * date or filtered according to a given filter).
 */
public interface INewsUpdatesCenter {

		
	/**
	 * 
	 * Registers a new listener which will be notified when the database is updated.
	 */
	public abstract void registerNewsUpdateReceivedListener(INewsUpdateReceivedListener listener);

			
	/**
	 * 
	 * Unregisters a listener.
	 */
	public abstract void unregisterNewsUpdateReceivedListener(INewsUpdateReceivedListener listener);


				
	/**
	 * 
	 * Retrieves all new updates sorted according to publish date.
	 */
	public abstract SortedSet<INewsItem> fetchNewsSortedByDate();


					
	/**
	 * 
	 * Retrieves all new updates sorted according to publish date and filtered according
	 * to the given filter (Stock Symbol).
	 */
	public abstract SortedSet<INewsItem> fetchNewsSortedByFilter(String filter);


						
	/**
	 * 
	 * Updates the News Updates Center with the given collection of news items.
	 */
	public abstract void updateNewsCenter(List<INewsItem> items);
}
